""" DigitalICS: mobile data collection tool to complete surveys with integrated multimedia

    Copyright (C) 2009. Yael Schwartzman  

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>
    
    Contact information: Yael Schwartzman -  yaelsf@gmail.com
    """


class Constants: 
    """ Defines possible types of Input and Output """ 
    def __init__(self):
    	#return types
    	self.RETURN_INTEGER = 1 
    	self.RETURN_STRING = 2 
    	self.RETURN_DATE = 3 
    	self.RETURN_FLOAT = 4 
    	self.RETURN_BOOLEAN = 5 
    	
    	
    	#form control types
    	self.INPUT = 1 
    	self.SELECT1 = 2 
    	self.SELECT = 3 
    	self.TEXTAREA = 4 
    	self.AUDIO = 5
    	self.PHOTO = 6
    	self.FORM = 7
    	self.FEEDBACK = 9
        self.DB_INPUT = 10
    	
    	#if page is on front_page view
    	self.FRONT = 8
	
	
	def get_constant(self, label,value):
		if label == u'type':
			if value == u"number":  
				return self.RETURN_INTEGER 
			elif value == u"string": 
				return self.RETURN_STRING 
			elif value == u"date":
				return self.RETURN_DATE
			elif value == u"select1":  
				return self.RETURN_SELECT1 
			elif value == u"select":  
				return self.RETURN_SELECT_MULTI 
			elif value == u"boolean":
				return self.RETURN_BOOLEAN 
			elif value == u"audio":
				return self.RETURN_AUDIO 
			elif value == u"photo":
				return self.RETURN_PHOTO
			else:
				raise Exception(" constant not found %s: %s " % (label,value))
		
		elif label == u'input_type': 
			if value == u"input":
				return self.INPUT 
			elif value == u"select1":
				return self.SELECT1 
			elif value == u"select":
				return self.SELECT 
			elif value == u"textarea":
				return self.TEXTAREA 
			elif value == u"audio":
				return self.AUDIO 
			elif value == u"photo":
				return self.PHOTO 
			elif value == u"form":
				return self.FORM
			else:
				raise Exception(" constant not found %s: %s " % (label,value))
				
	def get_name(self,label, value):
		if label == u'type':
			if value == self.RETURN_INTEGER :
				return "number"
			elif value == self.RETURN_STRING :
				return "string"
			elif value == self.RETURN_DATE:
				return "date"
			elif value == self.RETURN_SELECT1 :
				return "select1"
			elif value == self.RETURN_SELECT_MULTI :
				return "select"
			elif value == self.RETURN_BOOLEAN :
				return "boolean"
			elif value == self.RETURN_AUDIO :
				return "audio"
			elif value == self.RETURN_PHOTO :
				return "photo"
			else:
				raise Exception(" constant namne not found %s: %s " % (label,value))
		
		elif label == u'input_type': 
			if value == self.INPUT :
				return "input"
			elif value == self.SELECT1 :
				return "select1"
			elif value == self.SELECT :
				return "select"
			elif value == self.TEXTAREA :
				return "textarea"
			elif value == self.AUDIO :
				return "audio"
			elif value == self.PHOTO :
				return "photo"
			elif value == self.FORM:
				return "form"
			else:
				raise Exception(" constant name not found %s: %s " % (label,value))
